< previous page page_601 next page >

Page 601
8694cbadb9b1ef7075903f6f95fc1db2.gif
Text1(txtCount).Visible = True
End Sub

Private Sub Form_Load()
txtTop = 120
txtLeft = 120
txtHeight = 495
txtWidth = 1215
txtCount = 0
End Sub

However, this code will keep adding controls on this form even if there is no longer any room for them to be displayed.
Day 6, Procedures, Functions, and Logic
Quiz
8694cbadb9b1ef7075903f6f95fc1db2.gif
1. A function can return only a single value; however, by using the byRef keyword, the function can modify any of the variables that were passed to it.
8694cbadb9b1ef7075903f6f95fc1db2.gif
2. The only difference between a subroutine and a function is that a function returns a value, while a subroutine does not.
8694cbadb9b1ef7075903f6f95fc1db2.gif
3. Using public variables is not recommended because they can be accessed anywhere in the application code, and you could wind up accidentally modifying a value. This would result in unexpected errors in the application.
8694cbadb9b1ef7075903f6f95fc1db2.gif
4. You can leave any subroutine or object's event routine by using the Exit Sub statement.
Exercise..
The first part of this exercise will print all the variables because the procedure-level variables are in the routine that will be printing them. However, the second part of the exercise will result in a runtime error because the procedure-level variables are not accessible. Listing A.2 shows the code to perform the tasks for this exercise. You will also need to add a module to the application as shown in Listing A.3.
LISTING A.2. CHAP6EX1.TXTFORM MODULE CODE FOR THE EXERCISE.

8694cbadb9b1ef7075903f6f95fc1db2.gif
Option Explicit

Private mVar1 As Integer
Private mVar2 As String

 
< previous page page_601 next page >

If you like this book, buy it!